package org.gdpu.service.impl;

import org.gdpu.base.DaoSupport;
import org.gdpu.model.Subject;
import org.gdpu.service.SubjectService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.Query;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-6-5
 * Time: 下午9:05
 * To change this template use File | Settings | File Templates.
 */
@Service
@Transactional
public class SubjectServiceImpl extends DaoSupport<Subject> implements SubjectService {

    @Override
    public Subject findSubjectBySubjectName(String subjectName) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("subjectName", subjectName);
        return (Subject) this.findSpecialObject(Subject.class, params);
    }

    @Override
    public List<Subject> allSubject(){
        Query query = em.createQuery("from Subject s");
        return query.getResultList();
    }

}
